﻿function actionActivity(){ //红包活动
    $.ajax({
        url: "/app/Marketing/GetMarketingState",
        success: function (getState) {
            if (getState.b == 1) { //  返回 activity:活动数据 是第一次扫码
                $.ajax({
                    type: "get",
                    url: '/app/WebTemplate/GetAwards',
                    data: { address: address },
                    async: false,
                    success: function (res) {
                        var Denomination = res.Denomination;
                        if (res.Denomination == -1) { //没有中到奖品
                            GetError(TemplateID);
                        }
                        else {  //中到奖品了
                            if (res.type == 3) { //流量
                                res.Denomination = res.Name;
                            }
                            else if (res.type == 2) {//优惠券
                            }
                            else { //红包
                                $('.bg-con .small-bg #showMoney').text(res.Denomination).parent().next().text(res.EnterpriseName).next().text(res.Name);
                                $('.bg-con .small-bg .add').attr('href', 'Verification?awId=' + res.Id + '&Aid=' + res.ActivityId + '&Denomination=' + Denomination);
                                $('.bg-con').css('display', 'block').children('.small-bg').children('p:nth-child(1)').addClass('animated bounceInLeft');
                                $('.bg-con').children('.small-bg').children('a.add').addClass('animated  zoomIn');
                            }
                        }
                    }
                });

            }
            else if (getState.b == 2) {//有活动 奖品已被领取
                var Nickname = decode(getState.record.Nickname);
                GetYet(TemplateID, Nickname);
            }
            else if (getState.b == 3) {//有活动 活动被扫码过  但用户没有领取 两次扫码已确定是同一个人  返回   activity:活动数据， Awards：中奖奖项 , record：中奖记录

                if (getState.record.Denomination == -1) { //没有中到奖品
                    GetError(TemplateID);
                }
                else {  //中到奖品了
                 
                    if (getState.Awards.type == 3) { //流量
                        getState.record.Denomination = getState.Name || '流量包';
                    }
                    else if (getState.Awards.type == 2) {//优惠券
                    }
                    else { //红包
                        $('.bg-con .small-bg p:nth-child(1) span').text(getState.Awards.Denomination);
                        $('.bg-con .small-bg p:nth-child(2)').text(getState.Awards.EnterpriseName);
                        $('.bg-con .small-bg p:nth-child(3)').text(getState.Awards.Name);
                        $('.bg-con .small-bg .add').attr('href', 'Verification?awId=' + getState.Awards.Id + '&Aid=' + getState.Awards.ActivityId + '&Denomination=' + getState.Awards.Denomination);
                        $('.bg-con').css('display', 'block').children('.small-bg').children('p:nth-child(1)').addClass('animated bounceInLeft');
                        $('.bg-con').children('.small-bg').children('a.add').addClass('animated  zoomIn');
                    }
                  
                }
            }
        }
    });
}